package net.jalbum.filters;

import javax.swing.JPanel;

public class BoxPanel extends ResizableObjectPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4709218896876154263L;
	protected ResizableBox resizableBox;
	protected BoxControl boxControl;
	
	public BoxPanel(){
		boxControl = new BoxControl(this);
		resizableBox = new ResizableBox();
		resizableBox.setParentPanel(this);
		resizableObject = resizableBox;
	}
	
	public JPanel getControls(){
		return boxControl;
	}
	
	public ResizableBox getResizableBox(){
		return resizableBox;
	}

	public void setResizableBox(ResizableBox resizableBox) {
		this.resizableBox = resizableBox;
	}


	public void updateController(double x1, double y1, double x2,double y2) {
		this.X1 = x1;
		this.Y1 = y1;
		this.X2 = x2;
		this.Y2 = y2;
		resizableObjectControl.update(x1,y1,x2-x1,y2-y1);
		renderPreview();		
	}
	
	public void updateObject(double x1, double y1, double width, double height){
		//this method is called by the controller to pass new settings to the object
		this.X1 = x1;
		this.Y1 = y1;
		this.X2 = width+x1;
		this.Y2 = height+y1;
		resizableObject.update(x1,y1,width+x1,height+y1);
		resizableObject.setInitial(false);
		renderPreview();		
	}
}
